﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MicroLibraryAssembly;
using System.Collections;
using System.Data;
using System.Web.UI.WebControls;
using System.Text;
using System.Net.Mail;
using System.Net;
public static class CommonClass
{
    #region Data Manipulate methods
    public static bool ActiveInactiveItem(int id, string status, string strTableName, string strPKName)
    {
        return DependentMicroLibrary.ActiveInactiveItem(id, status, strTableName, strPKName, ConfigClass.DbConn, "IsActive");
    }
    public static bool DeleteSelectedRecords(string strDelIDs, string strTableName, string strPKName)
    {
        return DependentMicroLibrary.DeleteSelectedRecords(strDelIDs, strTableName, strPKName, ConfigClass.DbConn);
    }
    public static DataSet GetListing(string strSearchText, bool mode, string strPageCode, int ID, String Parameter1)
    {
        return DependentMicroLibrary.GetListing(strSearchText, mode, strPageCode, ConfigClass.DbConn, ID, Parameter1);
    }
    public static Object GetDetails(string strPageCode, int ID, Object clsObject)
    {
        return DependentMicroLibrary.GetDetails(strPageCode, ID, clsObject, ConfigClass.DbConn);
    }
   
    public static Int32 AddUpdate(object clsObject, string pageName)
    {

        return DependentMicroLibrary.AddUpdate(clsObject, pageName, ConfigClass.DbConn);
    }
    public static bool CheckDuplicateName(string tableName, string field, string fieldValue, int intID, string parameter1)
    {
        return DependentMicroLibrary.CheckDuplicateName(tableName, field, fieldValue, intID, parameter1, ConfigClass.DbConn);
    }
    #endregion
    #region Send Email
    //public static Int32 SendMail(String To, String Subject, string fileName, Hashtable keywordsWithValues)
    //{
    //    return DependentMicroLibrary.SendMail(ConfigClass.emailHost, ConfigClass.emailNetworkUsername, ConfigClass.emailNetworkPassword, Convert.ToBoolean(ConfigClass.emailIsSSL), To, ConfigClass.EmailFrom, Subject, ConfigClass.emailTemplatePath, fileName, keywordsWithValues);
    //}

    #endregion
    #region Print Methods
    public static void PrintError(Literal litTemp, string errorCode)
    {
        DependentMicroLibrary.PrintError(litTemp, errorCode, ConfigClass.XmlMessageFilePath, ConfigClass.XmlMessageFileName);
    }
    public static void PrintMessage(Literal litTemp, string errorCode)
    {
        DependentMicroLibrary.PrintMessage(litTemp, errorCode, ConfigClass.XmlMessageFilePath, ConfigClass.XmlMessageFileName);
    }
    public static void PrintWarning(Literal litTemp, string errorCode)
    {
        DependentMicroLibrary.PrintWarning(litTemp, errorCode, ConfigClass.XmlMessageFilePath, ConfigClass.XmlMessageFileName);
    }
    #endregion


    public static String AddMarkerAndInfo(string declareMap, string Lat, string Long, string BallonInfo, string mapID)
    {
        StringBuilder cstext2Merchant = new StringBuilder();
        cstext2Merchant.Append(declareMap); // );
        cstext2Merchant.Append("marker = new google.maps.Marker({position: new google.maps.LatLng(" + Lat + "," + Long + "),map: " + mapID + "});");
        cstext2Merchant.Append("google.maps.event.addListener(marker, 'mouseover', (function (marker, i) {return function () { infowindow.setContent('" + BallonInfo + "rishi" + "'); infowindow.open(" + mapID + ", marker);} })(marker, i));");
        cstext2Merchant.Append("var myLatLng = new google.maps.LatLng(" + Lat + "," + Long + ");");
        cstext2Merchant.Append(mapID + ".setCenter(myLatLng);");
        cstext2Merchant.Append(Environment.NewLine);
        return cstext2Merchant.ToString();
    }
    public static String BallonInfoHTMLDatePlanner(string ImageFile, string ID, string Title, string offer, string UserID)
    {
        StringBuilder ballonInfo = new StringBuilder();
        ballonInfo.Append("<div style=\"width: 280px;overflow:none;\"><table border=\"0px\" ><tr><td style=\"vertical-align: top;\"><a href=\"MerchantDetail.aspx?UserID=" + UserID + "#tblMerchantDetail" + "\" > <img src=\"images/merchant/" + HttpUtility.HtmlEncode(ImageFile) + "\" width=\"90px\" height=\"60px\" /></td>");
        ballonInfo.Append(" <td valign=\"middle\"><a href=\"MerchantDetail.aspx?UserID=" + UserID + "#tblMerchantDetail" + "\" style=\"text-decoration: none; font-size: 15px;font-weight: bold; color: Black;\">" + HttpUtility.HtmlEncode(Title) + "</a>");
        ballonInfo.Append(" </td></tr></table><div style=\"height: 60px; overflow: auto; overflow-x: none;\"><table border=\"0px\" width=\"100%\" cellpadding=\"0px\" cellspacing=\"0px\">");
        ballonInfo.Append("<tr><td style=\"text-decoration: none; font-size: 13px;font-weight: bold; color: #78BE3A;\">" + HttpUtility.HtmlEncode(offer) + "</td></tr><tr>");
        ballonInfo.Append(" <td valign=\"middle\"><a href=\"MerchantDetail.aspx?UserID=" + UserID + "#tblMerchantDetail" + "\" style=\"text-decoration: none; font-size: 15px;font-weight: bold; color: Red;\">" + "-Click on Store Name For Detailed Info-" + "</a>");
        ballonInfo.Append("</td></tr></table> </div></div><br/>");
        return ballonInfo.ToString();
    }
    public static String BallonInfoHTML(string ImageFile, string ID, string Title, string address, string phone, string offer, string Offertimestart, string Offertimeend, string days)
    {
        StringBuilder ballonInfo = new StringBuilder();
        ballonInfo.Append("<div style=\"width: 250px;\"><table border=\"0px\" ><tr><td style=\"vertical-align: top;\"><img src=\"images/merchant/" + HttpUtility.HtmlEncode(ImageFile) + "\" width=\"60px\" height=\"60px\" /></td>");
        ballonInfo.Append(" <td valign=\"middle\"><a href=\"MerchantDetail.aspx?ID=" + ID + "#tblMerchantDetail" + "\" style=\"text-decoration: none; font-size: 15px;font-weight: bold; color: Black;\">" + HttpUtility.HtmlEncode(Title) + "</a>");
        ballonInfo.Append(" </td></tr></table><div style=\"height: 60px; overflow: auto; overflow-x: none;\"><table border=\"0px\" width=\"100%\" cellpadding=\"0px\" cellspacing=\"0px\">");
        ballonInfo.Append("<tr><td style=\"text-decoration: none; font-size: 13px;font-weight: bold; color: #78BE3A;\">" + HttpUtility.HtmlEncode(offer) + "</td></tr><tr><td style=\"text-decoration: none; font-size: 13px;font-weight: bold; color: #78BE3A;\">");
        ballonInfo.Append(HttpUtility.HtmlEncode( Offertimestart) + " - " + HttpUtility.HtmlEncode(Offertimeend) + "</td></tr><tr><td>" + HttpUtility.HtmlEncode(days));
        ballonInfo.Append( "</td></tr></table> </div></div>");
        return ballonInfo.ToString();
    }
    public static Boolean SendEmail(string Subj, string sendEmail,string Msg)
    {
        Boolean result = false;
        const string SERVER ="relay-hosting.secureserver.net";
        MailMessage objMail = new MailMessage();
        objMail.From = new MailAddress("info@thealohacard.com");
        objMail.To.Add(new MailAddress(sendEmail));
        objMail.IsBodyHtml = true;
        objMail.Subject = Subj;
        objMail.Priority = System.Net.Mail.MailPriority.High;
        objMail.Body = Msg;
        SmtpClient Client = new SmtpClient(SERVER, 25);
        Client.Credentials = CredentialCache.DefaultNetworkCredentials;
        Client.Send(objMail);
        return true;
       
    }
}
